# coding=utf-8
from django.contrib.auth.models import User
from django.db import models


class Tag(models.Model):
    tag_name = models.CharField(max_length=20, blank=True)
    create_time = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.tag_name


class Author(models.Model):
    name = models.CharField(max_length=30)
    email = models.EmailField(blank=True)
    website = models.URLField(blank=True)

    def __str__(self):
        return u'%s' % (self.name)


class Blog(models.Model):
    caption = models.CharField(max_length=50)
    author = models.ForeignKey(Author)
    tags = models.ManyToManyField(Tag, blank=True)
    content = models.TextField()
    publish_time = models.DateTimeField(auto_now_add=True)
    update_time = models.DateTimeField(auto_now=True)
    title_photo = models.CharField(max_length=50)

    def __str__(self):
        return u'%s %s %s' % (self.caption, self.author, self.publish_time)


class Plan(models.Model):
    Plan_name = models.CharField(max_length=50)
    Plan_about = models.CharField(max_length=50)
    Plan_ican = models.CharField(max_length=30, null=True)
    Plan_content_html = models.FileField(upload_to="templates/plan/", default="templates/plan/test.html")
    Plan_content = models.TextField()

    def __str__(self):
        return str(self.Plan_name)

    class Meta:
        verbose_name_plural = ('解决方案')


class Blog_user(models.Model):
    name = models.OneToOneField(User)
    signature = models.CharField(max_length=128, default='什么都没留下')
    photo = models.ImageField(upload_to="static/img/team/", default="static/img/team/4.jpg")

    def __str__(self):
        return str(self.name)


class Date_file(models.Model):
    date_file = models.CharField(max_length=50)

    def __str__(self):
        return self.date_file

    class Meta:
        verbose_name_plural = ('硬件展示标签')


class Photoprint(models.Model):
    date_file = models.ForeignKey(Date_file)
    date_src = models.ImageField(upload_to="static/img/portfolio/")
    date_name = models.CharField(max_length=50)

    def __str__(self):
        return self.date_name

    class Meta:
        verbose_name_plural = ('硬件展示')


class Love(models.Model):
    love_name = models.CharField(max_length=50)
    love_txt = models.CharField(max_length=50)
    love_ican = models.CharField(max_length=30)

    def __str__(self):
        return self.love_name


class Comments(models.Model):
    comments = models.CharField(max_length=30)
    blog_name = models.CharField(max_length=10)

    def __str__(self):
        return self.blog_name
